package com.xunlai.infra.permission.business.dao.repository;

import com.xunlai.infra.permission.business.dao.entity.vo.RouteTemplateCountVo;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author liang
 * @date 8/27/23 3:59 PM
 */
@Transactional(rollbackFor = Exception.class,readOnly = true)
public interface RouteTemplateCountRepository extends Repository<RouteTemplateCountVo,Long> {

    @Query("select route_template,count(DISTINCT id) as routeCount,count(DISTINCT route_subject) as subjectCount  from travel_route_info where route_template in (:ids) GROUP BY route_template ;")
    List<RouteTemplateCountVo> selectRouteCountByTemplateIn(@Param("ids") List<Long> templateIds);
}
